package com.fbli.controller;

import com.fbli.entity.Result;
import com.fbli.pojo.About;
import com.fbli.pojo.Knowledge;
import com.fbli.service.AboutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

@RestController
@RequestMapping("/about")
public class AboutController {
    @Autowired
    private AboutService aboutService;



    @RequestMapping("/abouts")
    @ResponseBody
    public About abouts(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        About about = aboutService.about(1);
         return about;
    }



    @RequestMapping("/update")
    public Result update(@RequestBody About about){
        try {
            aboutService.update(about);
            return new Result(true,"成功");
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,"异常，失败");
        }
    }

}
